﻿#region Using

using System;
using System.Timers;

#endregion

namespace ServerApplication.GameSession
{
    public class WorkItem
    {
        private readonly Timer timer;

        private readonly Action work;

        public WorkItem(Action work)
        {
            this.work = work;
            this.timer = new Timer(30);
            this.timer.Elapsed += this.TimerOnElapsed;
            this.timer.Start();
        }

        private void TimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            this.work();
        }

        public void Stop()
        {
            this.timer.Stop();
        }
    }
}